/**
 * Created by Mark_ren on 2016/11/28.
 * 苟富贵,無相忘
 */
var moment = require("moment");
var co = require('co');
var EventProxy = require('eventproxy');
var seqModule = require('../../../routes/createModules');
var seq = new seqModule();
var util = require('../../../common/util');


var pfTotalScoreController = {
    resultScore: function (req, res, next) {
        co(function () {
            var player = req.params.playerId;
            var sql = "select avg(total_score) as totalScore from pf_total_score where player_id = '" + player + "'";
            if (req.query.meetNum != undefined) {
                sql += " and meet_num='" + req.query.meetNum + "'";
            }
            seq.sequelize.query(sql).spread(function (result) {
                res.json({ 'success': true, 'msg': '查询成功', 'result': result[0].totalScore });
            })
        }).catch(function (e) {
            res.json({ 'success': false, 'msg': '查询失败' });
            console.log(e);
        })
    }
}
module.exports = pfTotalScoreController;